package vns.client.view;

import vns.shared.AccountData;
import vns.client.helper.Helper;
import vns.client.presenter.AccountPresenter;
import vns.client.service.AccountOAuthServiceAsync;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HasVerticalAlignment;

public class AccountUI extends Composite implements AccountPresenter.Display {

	private int loginState;

	private HTML h1;
	private HTML h2;
	private AccountOAuthServiceAsync rpc;
	private boolean loggedIn;
	private AccountData accountData;
	private HTML hNick;
	private AccountAccessButton accountAccessButton;
	private HTML hNote;
	private Button btlogin;

	public AccountUI() {
		init();
	}

	private void init() {
		VerticalPanel vpMain = new VerticalPanel();
		initWidget(vpMain);
		vpMain.setWidth("100%");

		VerticalPanel vpTop = new VerticalPanel();
		vpMain.add(vpTop);
		vpTop.setWidth("100%");

		HorizontalPanel horizontalPanel = new HorizontalPanel();
		vpTop.add(horizontalPanel);
		vpTop.setCellHorizontalAlignment(horizontalPanel,
				HasHorizontalAlignment.ALIGN_RIGHT);

		hNick = new HTML("&nbsp;", true);
		horizontalPanel.add(hNick);

		h1 = new HTML("&nbsp;", true);
		horizontalPanel.add(h1);

		h2 = new HTML("&nbsp;", true);
		horizontalPanel.add(h2);

		VerticalPanel verticalPanel_1 = new VerticalPanel();
		vpMain.add(verticalPanel_1);

		hNote = new HTML(
				"", true);
		verticalPanel_1.add(hNote);

		VerticalPanel vp = new VerticalPanel();
		vpMain.add(vp);
		vp.setWidth("100%");

		HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
		vp.add(horizontalPanel_1);

//		String scope = "http://www.blogger.com/feeds/";
		String scope = Helper.SCOPE;
		accountAccessButton = new AccountAccessButton(scope);
		horizontalPanel_1.add(accountAccessButton);
		
		btlogin = new Button("Vào phần mềm");
		btlogin.setVisible(false);
		horizontalPanel_1.add(btlogin);
		
		

		HTML htmlYouNeedAccess = new HTML(
				"", true);
		horizontalPanel_1.add(htmlYouNeedAccess);
		horizontalPanel_1.setCellVerticalAlignment(htmlYouNeedAccess,
				HasVerticalAlignment.ALIGN_MIDDLE);

		VerticalPanel verticalPanel = new VerticalPanel();
		vpMain.add(verticalPanel);

		HTML htmlnbsp = new HTML("&nbsp;", true);
		verticalPanel.add(htmlnbsp);
	}


	@Override
	public HTML getH1() {
		return h1;
	}

	@Override
	public HTML getH2() {
		return h2;
	}

	public HTML getHNick() {
		return hNick;
	}

	@Override
	public HTML getHNote() {
		return hNote;
	}

	@Override
	public Button getLoginButton() {
		return btlogin;
	}

	@Override
	public AccountAccessButton getAccountAccessButton() {
		return accountAccessButton;
	}

	@Override
	public AccountData getAccountData() {
		return accountData;
	}

	@Override
	public void setAccountData(AccountData accountData) {
		this.accountData = accountData;
	}

	@Override
	public void setLoginState(int loginState) {
		this.loginState = loginState;
	}
}
